<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" href="css/index.css" />
</head>

<body>
	<div id="adminsadd">
		<h2>添加管理员</h2>
		<el-form ref="loginform" :model="adminsObj" :rules="rules" label-width="100px" style="width:500px">
			<!-- <el-form-item label="管理员编号">
    				<el-input v-model="adminsObj.adminsId":disabled="true"></el-input>
  				  </el-form-item> -->
			<el-form-item label="管理员姓名" :required="true">
				<el-input v-model="adminsObj.adminsName"clearable></el-input>
			</el-form-item>

			<el-form-item label="管理员密码" :required="true">
				<el-input v-model="adminsObj.adminsPwd" type="password" show-password></el-input>
			</el-form-item>

			<el-form-item label="管理员电话" :prop="adminsTel"clearable>
				<el-input v-model="adminsObj.adminsTel"></el-input>
			</el-form-item>
			<el-form-item label="管理员身份" :required="true">
				<el-select v-model="adminsObj.adminsState" placeholder="请选择管理员身份"clearable>
					<el-option label="初级管理员" value="0"></el-option>
					<el-option label="高级管理员" value="1"></el-option>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" @click="insert">添加</el-button>
			</el-form-item>
		</el-form>

	</div>
	<script type="text/javascript" src="js/vue.js"></script>
	<script type="text/javascript" src="js/index.js"></script>
	<script type="text/javascript" src="js/axios.min.js"></script>

	<script type="text/javascript" src="js/common.js"></script>
	<script>
		export default {
			data() {
				return {
				
					adminsObj: {
						adminsTel: ""
					},
					rules: {
						adminsTel: [
							{ required: true, message: '请输入活动名称', trigger: 'blur' },
							{ min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }]

					}
				};
			},
			methods: {

			}
		}
	</script>
	<script type="text/javascript">
		new Vue({
			el: "#adminsadd",
			data: {
				adminsTel:"",
				adminsObj: {
					adminsId: "",
					adminsPwd: "",
					adminsName: "",
					adminsTel: "",
					adminsState: ""
				}
			},
			methods: {
				insert: function () {
					let that = this;
					let fm = new FormData();
					if (this.adminsObj.adminsName + '' == "") {
						that.$message.error("请输入姓名");
					}
					else if (this.adminsObj.adminsPwd + '' == "") {
						that.$message.error("请输入密码");

					}
					else if (this.adminsObj.adminsState + '' == "") {
						that.$message.error("请选择身份");
					}
					else {

						//fm.append("adminsId",this.adminsObj.adminsId);
						fm.append("adminsPwd", this.adminsObj.adminsPwd);
						fm.append("adminsName", this.adminsObj.adminsName);
						fm.append("adminsTel", this.adminsObj.adminsTel);
						fm.append("adminsState", this.adminsObj.adminsState);
						axios.post("/admins/insert", fm).then(function (r) {
							if (r.data.state == "success") {
								that.$message.success("添加管理员成功！");
								setTimeout("location.href='adminsList2.html'", 500);
							}
						});
					}
				}
			}
		});


	</script>

</body>

</html>